Skip to content

Commit e8afdbb

Browse files
committed
Setup initData specs
1 parent 7997a71 commit e8afdbb

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

specs/initData.spec.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict';
2+
3+
var fs = require('fs');
4+
var path = require('path');
5+
6+
var initDataModule = {
7+
path: '../lib/initData',
8+
require: function () {
9+
return require(this.path);
10+
},
11+
teardown: function () {
12+
delete require.cache[require.resolve(this.path)];
13+
}
14+
};
15+
16+
var defaultConfig = {
17+
path: path.join(__dirname, '../protractor-conf.js'),
18+
setup: function () {
19+
fs.writeFileSync(this.path, 'exports.config = {}');
20+
},
21+
teardown: function () {
22+
fs.unlinkSync(this.path);
23+
}
24+
};
25+
26+
var globalMocks = {
27+
setup: function () {
28+
global.protractor = {};
29+
global.browser = {
30+
addMockModule: function () {}
31+
};
32+
},
33+
teardown: function () {
34+
delete global.protractor;
35+
delete global.browser;
36+
}
37+
};
38+
39+
40+
describe('init data', function(){
41+
beforeEach(function () {
42+
this.initData = initDataModule.require();
43+
globalMocks.setup();
44+
defaultConfig.setup();
45+
});
46+
afterEach(function () {
47+
initDataModule.teardown();
48+
globalMocks.teardown();
49+
defaultConfig.teardown();
50+
});
51+
});

0 commit comments

Comments
 (0)