Skip to content

Commit

Permalink
tests: added editor & editor/render tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kelsk committed Apr 27, 2020
1 parent 5985740 commit 0d0e2ef
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion run/markdown-preview/editor/test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const supertest = require('supertest');

let request, template, htmlString, markdownString, falseString;

describe('Unit Tests', () => {
describe('Editor unit tests', () => {
before(async () => {
const {app, buildTemplate} = require(path.join(__dirname, '..', 'main'));
request = supertest(app);
Expand Down
39 changes: 39 additions & 0 deletions run/markdown-preview/editor/test/render.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const assert = require('assert');
const path = require('path');

let request, service, markdown;

describe('Editor renderRequest unit tests', () => {
before(async () => {
request = require(path.join(__dirname, '..', 'render'));
service = {url: 'https://www.google.com', isAuthenticated: false};
markdown = "**markdown text**";
});

it('can make an unauthenticated request', async () => {
const res = await request(service, markdown);
assert.deepStrictEqual(res.name, 'HTTPError');
})

it('can make an authenticated request with an invalid url', async () => {
service.isAuthenticated = true;
const res = await request(service, markdown);
assert.deepStrictEqual(res.name, 'HTTPError');
})
});

0 comments on commit 0d0e2ef

Please sign in to comment.