进行了一些小优化
This commit is contained in:
1 parent
2a3e8bf392
commit
2085a702b9
7 files changed
+350
-43
No files matched your search
@@ -0,0 +1,46 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('node:assert/strict')
|
||||
const path = require('node:path')
|
||||
const { spawnSync } = require('node:child_process')
|
||||
const test = require('node:test')
|
||||
|
||||
const root = path.resolve(__dirname, '../..')
|
||||
|
||||
test('user and author widgets render the reference state contract', () => {
|
||||
const result = spawnSync(process.env.PHP_BINARY || 'php', [path.join(__dirname, 'user-card-runtime-harness.php')], {
|
||||
cwd: root,
|
||||
encoding: 'utf8',
|
||||
})
|
||||
assert.equal(result.status, 0, result.stderr || result.stdout)
|
||||
const data = JSON.parse(result.stdout)
|
||||
|
||||
assert.match(data.guest, /^<div class="mb20"><div class="user-card zib-widget widget">/)
|
||||
assert.match(data.guest, /data-lazy-type="lazy_other"/)
|
||||
assert.match(data.guest, /alt="默认头像"/)
|
||||
assert.match(data.guest, /<div class="user-info mt10"><div class="text-center"><p class="muted-color box-body em12">/)
|
||||
assert.match(data.guest, /signin-loader but jb-blue padding-lg/)
|
||||
assert.match(data.guest, /signup-loader ml10 but jb-yellow padding-lg/)
|
||||
assert.match(data.guest, /social-separator separator muted-3-color em09 mt20 mb20/)
|
||||
assert.match(data.guest, /social_loginbar/)
|
||||
assert.match(data.guest, /class="social-login-item github"/)
|
||||
assert.match(data.guest, /class="social-login-item qq" data-provider="clogin_qq"/)
|
||||
assert.doesNotMatch(data.guest, /aksrt-widget|aksrt-panel-wrap|user-card__auth-btns|oauth-row|oauth-btn/)
|
||||
|
||||
assert.match(data.guest_no_registration, /signin-loader but jb-blue padding-lg/)
|
||||
assert.doesNotMatch(data.guest_no_registration, /signup-loader/)
|
||||
assert.equal(data.closed, '')
|
||||
|
||||
assert.match(data.logged, /^<div class="mb20"><div class="user-card zib-widget widget">/)
|
||||
assert.match(data.logged, /data-lazy-type="lazy_cover"/)
|
||||
assert.match(data.logged, /<div class="card-content mt10 relative">/)
|
||||
assert.match(data.logged, /<div class="user-name flex jc">/)
|
||||
assert.match(data.logged, /<div class="author-tag mt10 mini-scrollbar">/)
|
||||
assert.match(data.logged, /<div class="user-desc mt10 muted-2-color em09">/)
|
||||
assert.doesNotMatch(data.logged, /data-post-type=/)
|
||||
|
||||
assert.match(data.author, /^<div class="mb20"><div class="user-card zib-widget widget">/)
|
||||
assert.match(data.author, /data-lazy-type="lazy_cover"/)
|
||||
assert.match(data.author, /data-post-type="post" data-post-style="card"/)
|
||||
assert.doesNotMatch(data.author, /user-btns mt20/)
|
||||
})
|
||||
Reference in new issue
Block a user