add sinon for better testing
This commit is contained in:
parent
86f98206d9
commit
46c705bdfa
6 changed files with 128 additions and 11 deletions
|
@ -9,7 +9,7 @@ PatternDraftQueue.prototype.start = function () {
|
|||
}
|
||||
|
||||
PatternDraftQueue.prototype.addPart = function (partName) {
|
||||
this.queue.push(partName)
|
||||
if (!this.contains(partName)) this.queue.push(partName)
|
||||
return this
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,10 @@ PatternDraftQueue.prototype.next = function () {
|
|||
return next
|
||||
}
|
||||
|
||||
PatternDraftQueue.prototype.contains = function (partName) {
|
||||
return this.queue.indexOf(partName) !== -1
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the draft order based on the configuation
|
||||
*
|
||||
|
|
|
@ -67,8 +67,11 @@ export function Pattern(designConfig = {}) {
|
|||
* It might be useful to not resolve immediately if a number of parts will be added over multiple calls
|
||||
* @return {object} this - The Pattern instance
|
||||
*/
|
||||
Pattern.prototype.addPart = function (part, resolveImmediately = false) {
|
||||
if (this.__configResolver.isPartValid(part) && this.designConfig.parts.indexOf(part) === -1) {
|
||||
Pattern.prototype.addPart = function (part, resolveImmediately = true) {
|
||||
if (
|
||||
this.__configResolver.isPartValid(part) &&
|
||||
!this.designConfig.parts.find((p) => p.name == part.name)
|
||||
) {
|
||||
this.designConfig.parts.push(part)
|
||||
if (resolveImmediately) {
|
||||
if (this.__configResolver.addPart(part) && typeof this.draftQueue !== 'undefined')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue