Skip to content

Commit

Permalink
Add Deno tests and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jun 3, 2021
1 parent 9d4f04e commit eba2f2e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deno CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test-deno:
needs: build
runs-on: ubuntu-latest

strategy:
matrix:
deno: [v1.10.3]
node-version: 16.x
build-how: ["cdn"]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Deno ${{ matrix.deno }}
run:
curl -fsSL https://deno.land/x/install/install.sh | sudo
DENO_INSTALL=/usr/local sh -s ${{ matrix.deno }}
- run: npm install
- run: node ./tools/build.js -t ${{ matrix.build-how }}
- name: Run tests
run: deno test test/deno/index.ts
28 changes: 28 additions & 0 deletions test/deno/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { assertStrictEquals } from "https://deno.land/std@0.97.0/testing/asserts.ts";

import hljs from "../../build/es/core.js";
import js from "../../build/es/languages/javascript.min.js";

hljs.registerLanguage("javascript", js);

Deno.test({
name: "should return relevance key",
async fn() {
const out = hljs.highlight("", { language: "javascript" });
assertStrictEquals(out.relevance, 0);
},
});

Deno.test({
name: "should highlight block",
async fn() {
const code = 'var say = "Hello";';
const expected =
'<span class="hljs-keyword">' +
'var</span> say = <span class="hljs-string">' +
'&quot;Hello&quot;</span>;';

const out = hljs.highlight(code, { language: "javascript" });
assertStrictEquals(out.value, expected);
},
});

0 comments on commit eba2f2e

Please sign in to comment.