Skip to content

Commit 8814bcf

Browse files
committed
Merge pull request #7 from TryxAPI/fix-document-js
Update selecting directory. Cleanup / refactor document tests.
2 parents 91f06ea + a24ffd6 commit 8814bcf

5 files changed

Lines changed: 644 additions & 459 deletions

File tree

bin/lrs-test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
(function (process, require, program, exit, packageJson, Q, Joi, fs, path, Mocha) {
77
'use strict';
88

9+
var DIRECTORY = 'v1_0_2';
10+
911
program
1012
.version(packageJson.version)
1113
.usage('[options]')
12-
.option('-d, --directory [path]', 'test directory, default: test/v1_0_2')
14+
.option('-d, --directory [path]', 'test directory, default: ' + DIRECTORY)
1315
.option('-e, --endpoint <path>', 'the connection string')
1416
.option('-a, --basicAuth <true/false>', 'enables basic authentication')
1517
.option('-u, --authUser <username>', 'sets user name (required when basic authentication enabled)')
@@ -33,7 +35,7 @@
3335

3436
process.nextTick(function () {
3537
var options = {
36-
directory: program.directory || 'test/v1_0_2',
38+
directory: program.directory || DIRECTORY,
3739
endpoint: program.endpoint,
3840
basicAuth: program.basicAuth,
3941
authUser: program.authUser,
@@ -48,7 +50,7 @@
4850
process.env.BASIC_AUTH_ENABLED = options.basicAuth;
4951
process.env.BASIC_AUTH_USER = options.authUser;
5052
process.env.BASIC_AUTH_PASSWORD = options.authPass;
51-
var testDirectory = options.directory;
53+
var testDirectory = 'test/' + options.directory;
5254
fs.readdirSync(testDirectory).filter(function (file) {
5355
return file.substr(-3) === '.js';
5456
}).forEach(function (file) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lrs-conformance-tests",
3-
"version": "0.0.3",
3+
"version": "1.1.1",
44
"description": "lrs-conformance-tests",
55
"main": "test.js",
66
"scripts": {
@@ -42,6 +42,6 @@
4242
"super-request": "0.0.8",
4343
"supertest": "^0.13.0",
4444
"supertest-as-promised": "^1.0.0",
45-
"valid-url": "^1.0.9"
45+
"validator": "^3.39.0"
4646
}
4747
}

test/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
LRS_ENDPOINT=http://asdf.elmnts-test.com:8001/lrs
22
XAPI_VERSION=1.0.1
3+
DIRECTORY=v1_0_2
34
BASIC_AUTH_ENABLED=false
45
BASIC_AUTH_USER=username
56
BASIC_AUTH_PASSWORD=password

test/helper.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ if (!process.env.EB_NODE_COMMAND) {
1717
/** Appears to use relative path */
1818
var CONFIG_FOLDER_RELATIVE = './v1_0_2/configs';
1919

20+
/** Test directory */
21+
var DIRECTORY = process.env.DIRECTORY;
22+
2023
/** Defines endpoint of the LRS you are testing. Currently assumes authentication is not required */
2124
var LRS_ENDPOINT = process.env.LRS_ENDPOINT;
2225

@@ -315,7 +318,9 @@ if (!process.env.EB_NODE_COMMAND) {
315318
* @returns {string}
316319
*/
317320
buildActivity: function () {
318-
return 'http://www.example.com/activityId/hashset';
321+
return {
322+
activityId: 'http://www.example.com/activityId/hashset'
323+
};
319324
},
320325
/**
321326
* Returns an example State params.
@@ -350,7 +355,6 @@ if (!process.env.EB_NODE_COMMAND) {
350355
*/
351356
buildAgentProfile: function () {
352357
return {
353-
activityId: 'http://www.example.com/activityId/hashset',
354358
agent: {
355359
"objectType": "Agent",
356360
"account": {
@@ -396,7 +400,7 @@ if (!process.env.EB_NODE_COMMAND) {
396400
* @returns {object} statement
397401
*/
398402
buildStatement: function () {
399-
return clone(require('../data/statement_full.json'));
403+
return module.exports.clone(require('./' + DIRECTORY + '/templates/statements/default.json'));
400404
},
401405
/**
402406
* Deep clone object.

0 commit comments

Comments
 (0)