Skip to content

Commit

Permalink
fix(test): fix whitespacing in test
Browse files Browse the repository at this point in the history
Signed-off-by: Tatu Pesonen <tatupe360@hotmail.com>
  • Loading branch information
Tatu Pesonen committed Sep 14, 2021
1 parent 9112520 commit 983d27b
Showing 1 changed file with 28 additions and 43 deletions.
71 changes: 28 additions & 43 deletions tests/lib/util/parseMessage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,60 @@
import { MessageBlock, parseMessage } from '@/lib/util/MessageParser';
import { CodeBlock, Parser } from '@/lib/util/MessageParser';
import { readFileSync } from 'fs';
import path from 'path';

const input = readFileSync(path.join(__dirname, 'input.txt'), {
encoding: 'utf-8',
});
const parser = new Parser();

describe('Codeblock parser', () => {
test('parseMessage is defined', () => {
console.log(input);
expect(parseMessage).toBeDefined();
expect(parser.parseMessage(input)).toBeDefined();
});
test('Returns a properly parsed message', () => {
const blocks = parseMessage(input);
expect(blocks).toStrictEqual<MessageBlock[]>(messageBlockToExpect);
const blocks = parser.parseMessage(input);
expect(blocks).toStrictEqual<CodeBlock[]>(messageBlockToExpect);
});
});

const messageBlockToExpect: MessageBlock[] = [
{
content:
"Hey guys! I really need help with my code. I don't know what's wrong with it:",
order: 0,
type: 'text',
},
const messageBlockToExpect: CodeBlock[] = [
{
content: `const doCompany=async a=>try{const r=(await
axios.get(baseUrl+companyurl)).data.find(r=>r.name===a);
if(r)return r;{let r={name:a};if(201===(await axios.post
(baseUrl+companyurl,r)).status)return Logger.info("Created new company: " + a
),r}}catch(a){Logger.error(a)}};`,
order: 1,
axios.get(baseUrl+companyurl)).data.find(r=>r.name===a);
if(r)return r;{let r={name:a};if(201===(await axios.post
(baseUrl+companyurl,r)).status)return Logger.info("Created new company: " + a
),r}}catch(a){Logger.error(a)}};`,
order: 0,
languageKey: 'js',
type: 'code',
},
{
content: 'I also tried this:',
order: 2,
type: 'text',
},
{
content: 'if (r) return r;',
order: 3,
order: 1,
languageKey: 'js',
type: 'code',
},
{
content: "Also my HTML is really messed up, idk what's up with it:",
order: 4,
type: 'text',
},
{
content: '<div i="target"></div>',
order: 5,
order: 2,
languageKey: 'html',
type: 'code',
},
{
content: ` body {
background-color: lightblue;
}
h1 {
color: white;
text-align: center;
}
p {
font-family: verdana;
font-size: 20px;
}`,
order: 6,
content: `body {
background-color: lightblue;
}
h1 {
color: white;
text-align: center;
}
p {
font-family: verdana;
font-size: 20px;
}`,
order: 3,
languageKey: 'css',
type: 'code',
},
Expand Down

0 comments on commit 983d27b

Please sign in to comment.