1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const
|
13 | fs = require('fs'),
|
14 | path = require('path'),
|
15 | windowslib = require('..');
|
16 |
|
17 | describe('device', function () {
|
18 | it('namespace should be an object', function () {
|
19 | should(windowslib.device).be.an.Object;
|
20 | });
|
21 |
|
22 | ((process.env.JENKINS || process.platform !== 'win32') ? it.skip : it)('detect Windows Phone devices', function (done) {
|
23 | this.timeout(5000);
|
24 | this.slow(4000);
|
25 |
|
26 | windowslib.device.detect(function (err, results) {
|
27 | if (err) {
|
28 | return done(err);
|
29 | }
|
30 |
|
31 | should(results).be.an.Object;
|
32 | should(results).have.keys('devices', 'issues');
|
33 |
|
34 | should(results.devices).be.an.Array;
|
35 | results.devices.forEach(function (dev) {
|
36 | should(dev).be.an.Object;
|
37 | should(dev).have.properties('name', 'udid', 'index', 'wpsdk');
|
38 |
|
39 | should(dev.name).be.a.String;
|
40 | should(dev.name).not.equal('');
|
41 |
|
42 | should(dev.udid).be.a.Number;
|
43 |
|
44 | should(dev.index).be.a.Number;
|
45 |
|
46 | should(dev.wpsdk).not.be.ok;
|
47 | });
|
48 |
|
49 | should(results.issues).be.an.Array;
|
50 | results.issues.forEach(function (issue) {
|
51 | should(issue).be.an.Object;
|
52 | should(issue).have.keys('id', 'type', 'message');
|
53 | should(issue.id).be.a.String;
|
54 | should(issue.type).be.a.String;
|
55 | should(issue.type).match(/^info|warning|error$/);
|
56 | should(issue.message).be.a.String;
|
57 | });
|
58 |
|
59 | done();
|
60 | });
|
61 | });
|
62 |
|
63 | ((process.env.JENKINS || process.platform !== 'win32') ? it.skip : it)('connect to a device', function (done) {
|
64 | this.timeout(120000);
|
65 | this.slow(110000);
|
66 |
|
67 | windowslib.device.connect(0, done);
|
68 | });
|
69 |
|
70 | ((process.env.JENKINS || process.platform !== 'win32') ? it.skip : it)('install app on a device', function (done) {
|
71 | this.timeout(120000);
|
72 | this.slow(110000);
|
73 |
|
74 | windowslib.visualstudio.build({
|
75 | buildConfiguration: 'Debug',
|
76 | project: path.join(__dirname, 'TestApp', 'TestApp.csproj')
|
77 | }, function (err, result) {
|
78 | if (err) {
|
79 | return done(err);
|
80 | }
|
81 |
|
82 | var xapFile = path.join(__dirname, 'TestApp', 'Bin', 'Debug', 'TestApp_Debug_AnyCPU.xap');
|
83 | should(fs.existsSync(xapFile)).be.ok;
|
84 |
|
85 | windowslib.device.install(0, xapFile, function (err) {
|
86 | done(err);
|
87 | });
|
88 | });
|
89 | });
|
90 | });
|