1 |
|
2 |
|
3 |
|
4 |
|
5 | 'use strict';
|
6 |
|
7 | const fs = require('fs');
|
8 | const Log = require('log');
|
9 | const eol = require('eol');
|
10 | const GithubReader = require('../src/Readers/GithubReader');
|
11 |
|
12 | describe('GithubReader', () => {
|
13 |
|
14 | let reader;
|
15 |
|
16 | beforeEach(function () {
|
17 | reader = new GithubReader();
|
18 | reader.timeout = 30000;
|
19 |
|
20 |
|
21 | reader.logger = new Log(process.env.SPEC_LOGLEVEL || 'error');
|
22 | });
|
23 |
|
24 | it('should read sample#1 from GH', () => {
|
25 | let remote;
|
26 | const local = eol.lf(fs.readFileSync(__dirname + '/fixtures/sample-1/input.nut', 'utf-8'));
|
27 | reader.token = process.env.SPEC_GITHUB_TOKEN;
|
28 |
|
29 | remote = reader.read('github:electricimp/Builder/spec/fixtures/sample-1/input.nut@master');
|
30 | expect(remote).toEqual(local);
|
31 |
|
32 | remote = reader.read('github.com:electricimp/Builder/spec/fixtures/sample-1/input.nut');
|
33 | expect(remote).toEqual(local);
|
34 |
|
35 | remote = reader.read('github.com/electricimp/Builder/spec/fixtures/sample-1/input.nut');
|
36 | expect(remote).toEqual(local);
|
37 |
|
38 | remote = reader.read('github:electricimp/Builder/./spec/../spec/fixtures/sample-1/input.nut@master');
|
39 | expect(remote).toEqual(local);
|
40 |
|
41 | remote = reader.read('github.com:electricimp/Builder/./spec/../spec/fixtures/sample-1/input.nut');
|
42 | expect(remote).toEqual(local);
|
43 | });
|
44 |
|
45 | });
|