-
-
Notifications
You must be signed in to change notification settings - Fork 391
Expand file tree
/
Copy pathsetup.ts
More file actions
96 lines (85 loc) · 3.09 KB
/
setup.ts
File metadata and controls
96 lines (85 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// @ts-nocheck
/// <reference types="vitest/globals" />
import underscore from "underscore";
import Backbone from "backbone";
beforeEach(() => {
expect.hasAssertions();
});
globalThis._ = underscore;
globalThis.Backbone = Backbone;
_.templateSettings = {
evaluate: /\{\{(.+?)\}\}/g,
interpolate: /\{\{=(.+?)\}\}/g,
};
globalThis.CSRFToken = function () {
return "";
};
globalThis.requestHeaders = function () {
return { "X-CSRF-Token": CSRFToken() };
};
// Inject the story template into the DOM.
// This is a static test fixture extracted from _templates.html.erb,
// with the ERB t() call replaced by a plain string.
const templateHTML = [
'<script type="text/template" id="story-template">',
' <div class="row story-preview">',
' <div class="col-md-3">',
' <div class="story-starred" data-action="click->star-toggle#toggle:stop">',
' <i class="fa {{ if(is_starred) { }}fa-star{{ } else { }}fa-star-o{{ } }}" data-star-toggle-target="icon"></i>',
" </div>",
' <p class="blog-title">',
" {{= source }}",
" </p>",
" </div>",
' <div class="col-md-9">',
' <p class="story-details">',
' <span class="story-title">',
" {{= headline }}",
" </span>",
' <span class="story-lead">',
" — {{= lead }}",
" </span>",
" </p>",
" </div>",
" </div>",
"",
' <div class="story-body-container">',
' <div class="story-body">',
" <h1>",
' <a href="{{= permalink }}">{{= title }}</a>',
" {{ if (enclosure_url) { }}",
' <a class="story-enclosure" target="_blank" href="{{= enclosure_url }}">',
' <i class="fa fa-download"></i>',
" </a>",
" {{ } }}",
" </h1>",
" {{= body }}",
" </div>",
' <div class="row story-actions-container">',
' <div class="pull-left">',
' <span class="story-published">',
" {{= pretty_date }}",
" </span>",
" </div>",
' <div class="pull-right story-actions">',
' <div class="story-keep-unread" data-action="click->keep-unread-toggle#toggle:stop">',
' <i class="fa {{ if(keep_unread) { }}fa-check{{ } else { }}fa-square-o{{ } }}" data-keep-unread-toggle-target="icon"></i> Keep unread',
" </div>",
' <div class="story-starred" data-action="click->star-toggle#toggle:stop">',
' <i class="fa {{ if(is_starred) { }}fa-star{{ } else { }}fa-star-o{{ } }}" data-star-toggle-target="icon"></i>',
" </div>",
' <a class="story-permalink" target="_blank" href="{{= permalink }}">',
' <i class="fa fa-external-link"></i>',
" </a>",
" </div>",
" </div>",
" </div>",
"</script>",
].join("\n");
document.body.insertAdjacentHTML("beforeend", templateHTML);
window.HTMLElement.prototype.scrollIntoView = function () { /* noop */ };
import { Story, StoryView, StoryList, AppView } from "../../app/javascript/application";
globalThis.Story = Story;
globalThis.StoryView = StoryView;
globalThis.StoryList = StoryList;
globalThis.AppView = AppView;