/
tag_group_parser_spec.js
63 lines (53 loc) · 2.68 KB
/
tag_group_parser_spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require('../support/spec_helper');
describe("Cucumber.TagGroupParser", function() {
var Cucumber = requireLib('cucumber');
describe("parse()", function() {
it("splits two tags based on the separator", function() {
var tagGroupParser = Cucumber.TagGroupParser("@foo,@bar");
var parsed = tagGroupParser.parse();
expect(parsed).toEqual(["@foo", "@bar"]);
});
it("splits three tags based on the separator", function() {
var tagGroupParser = Cucumber.TagGroupParser("@foo,@bar,@baz");
var parsed = tagGroupParser.parse();
expect(parsed).toEqual(["@foo", "@bar", "@baz"]);
});
it("splits negative tags based on the separator", function() {
var tagGroupParser = Cucumber.TagGroupParser("@foo,~@bar,@baz");
var parsed = tagGroupParser.parse();
expect(parsed).toEqual(["@foo", "~@bar", "@baz"]);
});
it("removes leading and trailing whitespaces", function() {
var tagGroupParser = Cucumber.TagGroupParser("\t @foo, ~@bar ,\n @baz ");
var parsed = tagGroupParser.parse();
expect(parsed).toEqual(["@foo", "~@bar", "@baz"]);
});
});
describe(".getTagGroupsFromStrings()", function() {
var tagGroupStrings, getTagGroupsFromStringsFunc;
beforeEach(function() {
getTagGroupsFromStringsFunc = Cucumber.TagGroupParser.getTagGroupsFromStrings;
tagGroupStrings = [createSpy("first tag group string"), createSpy("second tag group string"), createSpy("third tag group string")];
tagGroups = [createSpy("first tag group"), createSpy("second tag group"), createSpy("third tag group")];
tagGroupParsers = [createSpyWithStubs("first tag group parser", {parse: tagGroups[0]}),
createSpyWithStubs("second tag group parser", {parse: tagGroups[1]}),
createSpyWithStubs("third tag group parser", {parse: tagGroups[2]})];
spyOn(Cucumber, 'TagGroupParser').andReturnSeveral(tagGroupParsers);
});
it("creates a TagGroupParser instance for each tag group string", function() {
getTagGroupsFromStringsFunc(tagGroupStrings);
tagGroupStrings.forEach(function(tagGroupString) {
expect(Cucumber.TagGroupParser).toHaveBeenCalledWith(tagGroupString);
});
});
it("gets the parsed tag groups", function() {
getTagGroupsFromStringsFunc(tagGroupStrings);
tagGroupParsers.forEach(function(tagGroupParser) {
expect(tagGroupParser.parse).toHaveBeenCalled();
});
});
it("returns the tag groups", function() {
expect(getTagGroupsFromStringsFunc(tagGroupStrings)).toEqual(tagGroups);
});
});
});