Download tasks/format-code-task-000037/tests/test.patch from FineEnvs/MiMo-V2.6-RL-harbor-code: direct link, hf CLI and curl.
- Browser
- Download file 3.97 kB
-
https://huggingface.co/datasets/FineEnvs/MiMo-V2.6-RL-harbor-code/resolve/main/tasks/format-code-task-000037/tests/test.patch
- Command line
-
hf download hf://datasets/FineEnvs/MiMo-V2.6-RL-harbor-code/tasks/format-code-task-000037/tests/test.patch
-
curl -L -o test.patch https://huggingface.co/datasets/FineEnvs/MiMo-V2.6-RL-harbor-code/resolve/main/tasks/format-code-task-000037/tests/test.patch
3.97 kB
| diff --git a/packages/components/psammead-social-embed/src/Notice/index.test.jsx b/packages/components/psammead-social-embed/src/Notice/index.test.jsx | |
| new file mode 100644 | |
| index 000000000..ad2a67723 | |
| --- /dev/null | |
| +++ b/packages/components/psammead-social-embed/src/Notice/index.test.jsx | |
| +import React from 'react'; | |
| +import { render } from '@testing-library/react'; | |
| +import 'jest-styled-components'; | |
| +import Notice from './index'; | |
| + | |
| +const renderNotice = () => | |
| + render( | |
| + <Notice | |
| + provider="twitter" | |
| + service="news" | |
| + text="Sorry but we're having trouble displaying this content" | |
| + linkText="View content on %provider_name%" | |
| + linkTextSuffixVisuallyHidden=", external" | |
| + linkHref="embed-url" | |
| + warningText="Warning: BBC is not responsible for third party content" | |
| + />, | |
| + ); | |
| + | |
| +const KNOWN_COLOR_VALUES = [ | |
| + '#222222', | |
| + '#3F3F42', | |
| + '#6E6E73', | |
| + '#AEAEB5', | |
| + '#404040', | |
| + '#000000', | |
| + '#FFFFFF', | |
| + 'inherit', | |
| + 'transparent', | |
| + 'currentColor', | |
| +]; | |
| + | |
| +const hasRule = (element, property, value, modifier) => { | |
| + try { | |
| + if (modifier) { | |
| + expect(element).toHaveStyleRule(property, value, { modifier }); | |
| + } else { | |
| + expect(element).toHaveStyleRule(property, value); | |
| + } | |
| + return true; | |
| + } catch (e) { | |
| + return false; | |
| + } | |
| +}; | |
| + | |
| +const getExplicitColor = (wrapper, modifier) => { | |
| + for (let i = 0; i < KNOWN_COLOR_VALUES.length; i += 1) { | |
| + const c = KNOWN_COLOR_VALUES[i]; | |
| + if (hasRule(wrapper, 'color', c, modifier)) return c; | |
| + } | |
| + return null; | |
| +}; | |
| + | |
| +const getWrapperColor = wrapper => { | |
| + for (let i = 0; i < KNOWN_COLOR_VALUES.length; i += 1) { | |
| + const c = KNOWN_COLOR_VALUES[i]; | |
| + if (hasRule(wrapper, 'color', c)) return c; | |
| + } | |
| + return null; | |
| +}; | |
| + | |
| + | |
| +const effectiveColorIs = (wrapper, modifier, color) => { | |
| + if (!modifier) return hasRule(wrapper, 'color', color); | |
| + const explicit = getExplicitColor(wrapper, modifier); | |
| + if (explicit && explicit !== 'inherit') return explicit === color; | |
| + return getWrapperColor(wrapper) === color; | |
| +}; | |
| + | |
| +describe('Notice fallback colours', () => { | |
| + it('paragraph text should render as C_SHADOW (#3F3F42)', () => { | |
| + const { container } = renderNotice(); | |
| + expect(effectiveColorIs(container.firstChild, 'p', '#3F3F42')).toBe(true); | |
| + }); | |
| + | |
| + it('warning (small) text should render as C_SHADOW (#3F3F42)', () => { | |
| + const { container } = renderNotice(); | |
| + expect(effectiveColorIs(container.firstChild, 'small', '#3F3F42')).toBe( | |
| + true, | |
| + ); | |
| + }); | |
| + | |
| + it('paragraph text should no longer render as C_EBON (#222222)', () => { | |
| + const { container } = renderNotice(); | |
| + expect(effectiveColorIs(container.firstChild, 'p', '#222222')).toBe(false); | |
| + }); | |
| + | |
| + it('link should render as C_EBON (#222222)', () => { | |
| + const { container } = renderNotice(); | |
| + expect(effectiveColorIs(container.firstChild, 'a', '#222222')).toBe(true); | |
| + }); | |
| + | |
| + it('link should not render as C_SHADOW (#3F3F42)', () => { | |
| + const { container } = renderNotice(); | |
| + expect(effectiveColorIs(container.firstChild, 'a', '#3F3F42')).toBe(false); | |
| + }); | |
| + | |
| + it('visited link should remain C_METAL (#6E6E73)', () => { | |
| + const { container } = renderNotice(); | |
| + expect(container.firstChild).toHaveStyleRule('color', '#6E6E73', { | |
| + modifier: 'a:visited', | |
| + }); | |
| + }); | |
| +}); | |
| diff --git a/test_commands.json b/test_commands.json | |
| new file mode 100644 | |
| index 000000000..4d8854ef1 | |
| --- /dev/null | |
| +++ b/test_commands.json | |
| +{ | |
| + "test_commands": ["npx jest packages/components/psammead-social-embed/src/Notice/index.test.jsx --no-coverage --ci"] | |
| +} | |
| diff --git a/mimo_test_command.sh b/mimo_test_command.sh | |
| new file mode 100755 | |
| --- /dev/null | |
| +++ b/mimo_test_command.sh | |
| +#!/usr/bin/env bash | |
| + | |
| +set -uo pipefail | |
| +cd /testbed | |
| +rc=0 | |
| +npx jest packages/components/psammead-social-embed/src/Notice/index.test.jsx --no-coverage --ci | |
| +rc=$(( rc | $? )) | |
| +exit $rc | |