UNPKG

1.45 kBJavaScriptView Raw
1// Copyright (c) 2016-2019 Electric Imp
2// This file is licensed under the MIT License
3// http://opensource.org/licenses/MIT
4
5'use strict';
6
7const fs = require('fs');
8const Log = require('log');
9const eol = require('eol');
10const GithubReader = require('../src/Readers/GithubReader');
11
12describe('GithubReader', () => {
13
14 let reader;
15
16 beforeEach(function () {
17 reader = new GithubReader();
18 reader.timeout = 30000; // 30s
19
20 // @see https://www.npmjs.com/package/log#log-levels
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});