Skip to content

Commit

Permalink
WIP: add more test code for input option
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Ceyer committed Jun 17, 2018
1 parent 8252c2f commit f8781ec
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/ui/ui.spec.ts
Expand Up @@ -79,4 +79,64 @@ describe('test class: UI', () => {
expect($afterBlurCursor.length).to.be.equal(0);
});
});

describe('test option: input()', () => {
it('should returns 1 + 2 + 3 with input() function', done => {
let streamIndex = 0;
const data = {
operator: '+',
operand1: {
operator: '+',
operand1: { value: { type: 'unit', unit: 1 } },
operand2:{ value: { type: 'unit', unit: 2 } }
},
operand2: { value: { type: 'unit', unit: 3 } }
};
const ui = new UI(elem, {
input: value => {
streamIndex += 1;
if (streamIndex < 6)
return;

try {
expect(value).to.be.deep.equal(data);
done();
} catch(e) {
done(e);
}
}
});

ui.setData(data);
});

it('should returns 1 + 2 + 3 with on(`input`) function', done => {
const ui = new UI(elem);
const data = {
operator: '+',
operand1: {
operator: '+',
operand1: { value: { type: 'unit', unit: 1 } },
operand2:{ value: { type: 'unit', unit: 2 } }
},
operand2: { value: { type: 'unit', unit: 3 } }
};
let streamIndex = 0;

$(elem).on(`${ui.options.id}.input`, (_: JQuery.Event, value) => {
streamIndex += 1;
if (streamIndex < 6)
return;

try {
expect(value).to.be.deep.equal(data);
done();
} catch(e) {
done(e);
}
});

ui.setData(data);
});
});
});
1 change: 1 addition & 0 deletions tslint.json
Expand Up @@ -7,6 +7,7 @@
"brace-style": [true, "1tbs", {
"allowSingleLine": true
}],
"ter-arrow-parens": false,
"no-namespace": false,
"no-conditional-assignment": false,
"max-line-length": [true, 120],
Expand Down

0 comments on commit f8781ec

Please sign in to comment.