This repository was archived by the owner on Sep 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathfunctional.js
88 lines (69 loc) · 2.19 KB
/
functional.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* @license
*
* Copyright (c) 2017, IBM.
*
* This source code is licensed under the Apache License, Version 2.0 found in
* the LICENSE.txt file in the root directory of this source tree.
*/
'use strict';
const assert = require('assert');
// eslint-disable-next-line import/no-extraneous-dependencies
const Cloud = require('@qiskit/cloud');
const algo = require('..');
const { version } = require('../package');
const cloud = new Cloud();
global.qiskit = {};
// TODO: Use utils.difference instead.
function multiIncludes(text, values) {
return values.every(val => text.includes(val));
}
describe('algo:ibm:api', () => {
it('should include all documented items', () => {
assert.ok(multiIncludes(Object.keys(algo), ['random', 'result']));
});
it('should return the the correct result for its methods', () =>
assert.equal(algo.version, version));
});
describe('algo:ibm:version', () =>
it('should be correct', () => assert.equal(algo.version, version)));
let jobId;
describe('algo:ibm:random', () => {
before(async function t() {
if (!process.env.QX_KEY) {
cloud.token = 'notvalid';
cloud.userId = 'notvalid';
/* eslint-disable no-console */
console.log(
'\n\n\n\t-------------------------------------------------------------',
);
console.log('\tWARNING');
console.log('\tQX_KEY env var not found, so skipping integration tests.');
console.log(
'\t-------------------------------------------------------------\n\n\n',
);
/* eslint-enable no-console */
this.skip();
}
global.qiskit.cloud = cloud;
await cloud.login(process.env.QX_KEY);
});
it('should return a jobId', async () => {
if (!global.qiskit || !global.qiskit.cloud) {
this.skip();
}
const res = await algo.random({ custom: cloud });
assert.equal(typeof res, 'string');
assert(res.length >= 0);
jobId = res;
});
});
describe('algo:ibm:result', () => {
it('should return the result passing jobId', async function t() {
if (!global.qiskit || !global.qiskit.cloud) {
this.skip();
}
const res = await algo.result(jobId, { custom: cloud });
assert.equal(res.status, 'running');
});
});